﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace AgFractal.Fractals
{
    public class FractalParameter : INotifyPropertyChanged
    {
        public string Name { get; set; }
        public string Description { get; set; }
        public ParameterType Type { get; set; }

        private double _R;
        public double R
        {
            get { return _R; }
            set
            {
                if (value == _R)
                    return;
                _R = value;
                NotifyChange("R");
            }
        }

        private double _I;
        public double I
        {
            get { return _I; }
            set
            {
                if (value == _I)
                    return;
                _I = value;
                NotifyChange("I");
            }
        }

        public Complex ComplexValue
        {
            get { return new Complex(R, I); }
            set
            {
                I = value.i;
                R = value.r;
            }
        }

#region INotifyPropertyChanged Members

        private void NotifyChange(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
